#include "../source/common/dispatcher.hpp"
#include "../source/server/rpc_server.hpp"


using namespace zyb_rpc;
using namespace std;
void Add(const Json::Value &req, Json::Value &rsp)
{
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;
}
int main()
{
    std::unique_ptr<server::SDescribeFactory> desc_factory(new server::SDescribeFactory());
    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1", server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2", server::VType::INTEGRAL);
    desc_factory->setReturnType(server::VType::INTEGRAL);
    desc_factory->setCallback(Add);
    
    server::RpcServer server({"127.0.0.1", 9090}, true, {"127.0.0.1", 8080});
    server.registerMethod(desc_factory->build());
    server.start();
}
